
var express = require("express");
var router = express.Router();
const user = require("../sql/user");
const registerpassword = require("../sql/registerpassword");
 
router.get('/',function(req,res,next){
    console.log('进来registerpassword里面了')
    res.render('registerpassword')
})

// 登录的第二步  <form action="/login/in" method="post">

router.post('/in',function(req,res,next) {
    
    let obj = req.body 
    console.log(obj)
    
    registerpassword.findOne({code:obj.code},(err,data)=>{


        if(err) {
            console.log('err')
        }
        if(data) {
            console.log('已经有了这个邀请码')
            return 
        }else {
            registerpassword.insertMany(obj,(err,data)=>{
                if(err) {
                    console.log('err')
                }
                console.log('邀请码加入成功')
               
            })
        }
    })
   
})


 




module.exports = router;